<template>
  <div class="newsinfo-tmpl">
    <h4 class="title">{{info.title}}</h4>

    <p class="info">
      <span>发表时间：{{info.add_time | dataFormat}}</span>
      <span>点击{{info.click}}次</span>
    </p>

    <hr>

    <div class="content" v-html="info.content"></div>

    <comment :artId="id"></comment>
  </div>
</template>

<script>
import comment from '../subcom/comment.vue'

export default {
  data() {
    return {
      id: this.$route.params.id,
      info: {}
    }
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      var url = 'api/getnew/' + this.id;
      this.$http.get(url).then(res => {
        var result = res.body;
        if (result.status === 0) {
          console.log(result.message);
          this.info = result.message[0];
        } else {
          console.log('获取新闻详情失败！');
        }
      });
    }
  },
  components: { comment }
}
</script>

<style lang="scss">
.newsinfo-tmpl {
  padding: 0 3px;

  .title {
    color: #26A2FF;
    margin: 15px 0;
    font-size: 15px;
    text-align: center;
  }

  .info {
    display: flex;
    justify-content: space-between;
  }

  .content {
    img {
      width: 100%;
    }
  }
}
</style>
